package com.zrf.base.knowledge.guava;

import com.google.common.base.Throwables;

import java.io.IOException;

/**
 * @author zhouruifeng
 *         Created by zhouruifeng on 2017/7/17.
 */
public class ThrowablesTest {
    public static void main(String[] args) throws Exception {
        try {
            throw new IOException("test");
        } catch (Exception e) {
            System.out.println(Throwables.getCausalChain(e));
            System.out.println(Throwables.getRootCause(e));
            System.out.println(Throwables.getStackTraceAsString(e));
            System.out.println(Throwables.lazyStackTrace(e));
            System.out.println(Throwables.lazyStackTraceIsLazy());
            Throwables.propagateIfPossible(e, RuntimeException.class);
            Throwables.throwIfInstanceOf(e, Exception.class);
        }
    }
}
